
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:osg/controllers/http.dart';


class LotteryList extends StatefulWidget {
   
  @override
  State<LotteryList> createState() => _SettingPageState();
}

class _SettingPageState extends State<LotteryList> {
    RxList list=[].obs;

 getInfo(){
     Get.find<HTTPS>().getData('/turntable/log', {}).then((res){
      if(res!=null){
        list.value=res;
      }
    });
  }
   @override
  void initState() {
    super.initState();
     WidgetsBinding.instance.addPostFrameCallback((_) {
      getInfo();
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
           appBar: AppBar(
            backgroundColor: Color.fromRGBO(255, 255, 255, 1),
            title: Text('抽奖记录',style: TextStyle(fontSize: 16),),
            centerTitle: true
          ),
          body:
          Padding(padding: EdgeInsets.symmetric(horizontal: 15,vertical: 15),
          child:
          Obx(()=>
          ListView(
            children: [
              for(var item in list)
              Container(
                margin: EdgeInsets.only(bottom: 15),
                padding: EdgeInsets.symmetric(horizontal: 15,vertical: 15),
                decoration: BoxDecoration(
                  color: Color(0XFFF8F9FD),
                  borderRadius: BorderRadius.circular(10)
                ),
                child: Row(
                  children: [
                  CircleAvatar( 
                    radius: 17,
                   backgroundImage: NetworkImage('${item['headimg']}'),
                  ),
                  SizedBox(width: 10,),
                  Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                    Text('${item['username']}',style: TextStyle(fontSize: 14,color: Color(0XFF0F172B)),),
                    Text('${item['created_at']}',style: TextStyle(fontSize: 12,color: Color(0XFF999999)),)
                    ],
                  ),
                    Expanded(child: SizedBox()),
                    Text('${item['git']}',style: TextStyle(fontSize: 16,color: Color(0XFF0F172B)),)
                  ],
                ),
              ),
              
            ],
          )
          )
          ,
          )
           
    );
  }
}